<template>
  <ElAutocompleteBox :data="data" :dataName="dataName" :searchBtn="(queryString: string, row: any, dataInfo: any, getQuerySearch: Function) => {
    proxy.$api.System.QueryPageDictionaryValueDataList({
      pageIndex: 1,
      pageSize: 9999,
      queryDataBaseFiled: '',
      likeWords: queryString,
      dictionaryCode: type, //系统数据字典代码（唯一识别码）
      dicValueState: -1 //系统数据字典状态：1可用；0不可用，-1查询全部
    }).then((res: any) => {
      dataInfo.options = res.list.map((el: any) => ({
        ...el,
        label: el.displayValue,
        value: el.displayValue,
      }))
      getQuerySearch()
    });
  }" :addBtn="(value: string, dataInfo: any) => {
    proxy.$api.System.AddDictionaryValue({
      dictionaryCode: type,
      dicValue: value,
      displayValue: value,
      dicValueDesc: '',
      dicValueSort: 0
    }).then((res: any) => {
      if (dataCode) {
        data[dataCode] = res
      }
      proxy.$message('新增成功')
      dataInfo.isNew = false
    })
  }" @changeBtn="(item: any) => {
    if (dataCode) {
      data[dataCode] = item.dicValueCode
    }
  }" />
</template>
<script setup lang="ts">
const { proxy } = getCurrentInstance() as any;
const props = withDefaults(
  defineProps<{
    data?: any;
    dataName?: string;
    dataCode?: string;
    type?: string;
  }>(),
  {
    type: 'TagColor'
  },
);
const emit = defineEmits<{
  //fn为父组件引入子组件是定义的子组件事件属性，可随意定义
  (event: 'searchBtn'): void;
}>();
const searchBtn = () => {
  emit('searchBtn');
};
onMounted(() => {

});
</script>
<style scoped lang="scss"></style>